package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.entity.RegulatorCollectDataEntity;
import com.hzhr.iot.device.entity.ext.RegulatorCollectDataEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.pressureMonitor1_collectData.PressureMonitor1_CollectDataModel;
import com.hzhr.iot.device.model.pressureMonitor1_collectData.PressureMonitor1_CollectDataGetModel;
import com.hzhr.iot.device.queryModel.custom.RegulatorCollectDataCustomQueryModel;

@Component
public class RegulatorCollectDataConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public RegulatorCollectDataEntity pressureMonitor1_CollectDataModel2entity(PressureMonitor1_CollectDataModel in) {
        //未转换字段: iotDeviceId outStaFlowRate4 outPressure1 outStaFlowRate3 inPressure outPressure2 outStaFlowRate2 outStaFlowRate1 isValid updateTime collectDeviceId createTime outTemperature4 outStaTotalFlow2 outStaTotalFlow3 outPressure3 outTemperature2 outPressure4 outTemperature3 outStaTotalFlow1 state outTemperature1 outStaTotalFlow4 
        if (in == null) return null;
        RegulatorCollectDataEntity result = new RegulatorCollectDataEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setEnvTemperature(HzhrTypeUtil.float2float(in.getTemperature()));
        result.setPressure(HzhrTypeUtil.double2double(in.getPressure()));
        result.setCollectTime(HzhrTypeUtil.long2date(in.getCollectTime()));
        return result;
    }
    public RegulatorCollectDataEntity pressureMonitor1_CollectDataModel2entity(PressureMonitor1_CollectDataModel in, RegulatorCollectDataEntity ori) {
        //未转换字段: iotDeviceId outStaFlowRate4 outPressure1 outStaFlowRate3 inPressure outPressure2 outStaFlowRate2 outStaFlowRate1 isValid updateTime collectDeviceId createTime outTemperature4 outStaTotalFlow2 outStaTotalFlow3 outPressure3 outTemperature2 outPressure4 outTemperature3 outStaTotalFlow1 state outTemperature1 outStaTotalFlow4 
        if (in == null) return null;
        RegulatorCollectDataEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setEnvTemperature(HzhrTypeUtil.float2float(in.getTemperature()));
        result.setPressure(HzhrTypeUtil.double2double(in.getPressure()));
        result.setCollectTime(HzhrTypeUtil.long2date(in.getCollectTime()));
        return result;
    }
    public List<RegulatorCollectDataEntity> pressureMonitor1_CollectDataModelList2entityList(List<PressureMonitor1_CollectDataModel> in) {
        if (in == null) return null;
        List<RegulatorCollectDataEntity> result = new ArrayList<>();
        for (PressureMonitor1_CollectDataModel item : in) {
            result.add(pressureMonitor1_CollectDataModel2entity(item));
        }
        return result;
    }
    public PressureMonitor1_CollectDataModel entity2pressureMonitor1_CollectDataModel(RegulatorCollectDataEntity in) {
        //未转换字段: 
        if (in == null) return null;
        PressureMonitor1_CollectDataModel result = new PressureMonitor1_CollectDataModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setPressure(HzhrTypeUtil.double2double(in.getPressure()));
        result.setTemperature(HzhrTypeUtil.float2float(in.getEnvTemperature()));
        result.setCollectTime(HzhrTypeUtil.date2long(in.getCollectTime()));
        return result;
    }
    public List<PressureMonitor1_CollectDataModel> entityList2pressureMonitor1_CollectDataModelList(List<RegulatorCollectDataEntity> in) {
        if (in == null) return null;
        List<PressureMonitor1_CollectDataModel> result = new ArrayList<>();
        for (RegulatorCollectDataEntity item : in) {
            result.add(entity2pressureMonitor1_CollectDataModel(item));
        }
        return result;
    }
    public PressureMonitor1_CollectDataModel ext2pressureMonitor1_CollectDataModel(RegulatorCollectDataEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        PressureMonitor1_CollectDataModel result = new PressureMonitor1_CollectDataModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setPressure(HzhrTypeUtil.double2double(in.getPressure()));
        result.setTemperature(HzhrTypeUtil.float2float(in.getEnvTemperature()));
        result.setCollectTime(HzhrTypeUtil.date2long(in.getCollectTime()));
        return result;
    }
    public List<PressureMonitor1_CollectDataModel> extList2pressureMonitor1_CollectDataModelList(List<RegulatorCollectDataEntityExt> in) {
        if (in == null) return null;
        List<PressureMonitor1_CollectDataModel> result = new ArrayList<>();
        for (RegulatorCollectDataEntityExt item : in) {
            result.add(ext2pressureMonitor1_CollectDataModel(item));
        }
        return result;
    }
    public PressureMonitor1_CollectDataGetModel extList2pressureMonitor1_CollectDataGetModel(List<RegulatorCollectDataEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<PressureMonitor1_CollectDataModel> modelList = extList2pressureMonitor1_CollectDataModelList(extList);
        if (modelList == null) {
            PressureMonitor1_CollectDataGetModel result = new PressureMonitor1_CollectDataGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (PressureMonitor1_CollectDataModel model : modelList) {
                model.setTemperature(null);
                model.setPressure(null);
                model.setCollectTime(null);
            }
        }

        PressureMonitor1_CollectDataGetModel result = new PressureMonitor1_CollectDataGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public PressureMonitor1_CollectDataGetModel entity2pressureMonitor1_CollectDataGetModel(RegulatorCollectDataEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<RegulatorCollectDataEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2pressureMonitor1_CollectDataGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, RegulatorCollectDataEntityExt.class));
        return extList2pressureMonitor1_CollectDataGetModel(extList, total, changeCount, query);
     }
    public RegulatorCollectDataCustomQueryModel pressureMonitor1_CollectDataService_query2queryModel(Map<String, Object> query) {
        RegulatorCollectDataCustomQueryModel queryModel = new RegulatorCollectDataCustomQueryModel();

        Date _greaterthanorequal_collectTime = HzhrTypeUtil.object2date(query.get("_greaterthanorequal_collectTime"));
        if (_greaterthanorequal_collectTime != null) {
            queryModel.setGreaterthanorequal_collectTime(_greaterthanorequal_collectTime);
         }

        Date _greaterthan_collectTime = HzhrTypeUtil.object2date(query.get("_greaterthan_collectTime"));
        if (_greaterthan_collectTime != null) {
            queryModel.setGreaterthan_collectTime(_greaterthan_collectTime);
         }

        Date _lessthanorequal_collectTime = HzhrTypeUtil.object2date(query.get("_lessthanorequal_collectTime"));
        if (_lessthanorequal_collectTime != null) {
            queryModel.setLessthanorequal_collectTime(_lessthanorequal_collectTime);
         }

        Date _lessthan_collectTime = HzhrTypeUtil.object2date(query.get("_lessthan_collectTime"));
        if (_lessthan_collectTime != null) {
            queryModel.setLessthan_collectTime(_lessthan_collectTime);
         }

        Date _equal_collectTime = HzhrTypeUtil.object2date(query.get("_equal_collectTime"));
        if (_equal_collectTime != null) {
            queryModel.setEqual_collectTime(_equal_collectTime);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

